import * as Types from './mutation-types' /* 必须有“./” */
export default {
  [Types.USER_LOGIN] (state, data) {
    state.user = data
  },
  [Types.USER_LOGOUT] (state) { // 用户注销
    state.user = {} // 删除已有的userid
    state.user.photo = '/static/images/avator/nophoto.png'
    state.privilege = [] // 删除已有权限
  },
  [Types.CHECK_LOGIN] (state) {
    return state.user.userid !== '' || state.user.userid.length() > 0
  },
  [Types.UPDATE_TOKEN] (state, token) {
    if (state.token != null) {
      state.token = token
    }
  },
  [Types.GET_TOKEN] (state) {
    return state.user.token
  },
  [Types.USER] (state) {
    return state.user
  }
}
